home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
076-100
/
disk_096
/
warptext
/
warp.arc
/
Warp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-08-27
|
5KB
|
136 lines
/* WarpText Quickie Test Anson Mah 06/08/87
* For Lattice C
*
* NOTE: This test does not use any of the WarpText 2.0 routines as
* they did not exist when Anson wrote this.
* I made an example program for all of the routines but I
* couldn't get the $#%! assembler to assembler it! It kept
* giving me all sorts of strange errors on the second pass.
* I was able to test all the routines interactively in Forth
* so, while I know the new (and old) routines work, I have no
* program to give out that demonstrates them... Sorry,
* Bill.
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include "graphics/WarpText.h"
extern void InitWarpInfo(), GotoXY(), GetXY(), WarpText();
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase = NULL;
struct Window *w = NULL;
struct WarpInfo *winfo = NULL;
struct TextAttr taTopaz80 = { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT };
struct NewWindow wdef = {
0,0,640,200,
0,1,
CLOSEWINDOW,
WINDOWDRAG | WINDOWCLOSE | WINDOWDEPTH | SMART_REFRESH | ACTIVATE,
NULL, NULL,
"WarpText Test",
NULL, NULL,
0,0,640,200,
WBENCHSCREEN
};
void closestuff()
{
if (winfo) FreeMem(winfo, sizeof(struct WarpInfo));
if (w) CloseWindow(w);
if (GfxBase) CloseLibrary(GfxBase);
if (IntuitionBase) CloseLibrary(IntuitionBase);
XCEXIT(0);
}
void openstuff()
{
if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary(
"intuition.library", 33)))
closestuff();
if (!(GfxBase = (struct GfxBase *)OpenLibrary(
"graphics.library", 33)))
closestuff();
if (!(winfo = (struct WarpInfo *)AllocMem(sizeof(struct WarpInfo),
MEMF_PUBLIC)))
closestuff();
if (!(w = (struct Window *)OpenWindow(&wdef)))
closestuff();
}
ULONG strlen(s)
char *s;
{
ULONG i = 0;
while (*s++)
i++;
return(i);
}
void _main()
{
static char *text[17];
struct IntuiMessage *msg;
ULONG class;
UWORD i;
openstuff();
text[0] = "Hi, Bill!\n";
text[1] = " Thanx for your WarpText routines. As you can see, this\n";
text[2] = "is a quick test of 'em. The only routine I don't use is\n";
text[3] = "GetXY. Also note that I have created a WarpText.h file for\n";
text[4] = "C programmers like yours truly and also a C interface\n";
text[5] = "module for the same people! Please do what you will with\n";
text[6] = "them.\n";
text[7] = " Right. I've looked over your code and can't see any\n";
text[8] = "immediate improvements, but I may if I study them longer.\n";
text[9] = "Actually, I believe you might gain some more speed if you\n";
text[10] = "start using the Blitter instead. It was made to handle\n";
text[11] = "stuff like this. You should be able to get upward of\n";
text[12] = "30,000 chars/sec if you use it. This number was measured\n";
text[13] = "with the set of routines my friends came up with a while\n";
text[14] = "back. It's fairly accurate.\n";
text[15] = " Anyway, more when I have more time to hack!\n";
text[16] = " Anson";
/* set up WarpInfo */
winfo->wi_TextFont = (APTR)OpenFont(&taTopaz80);
winfo->wi_BitMap = (APTR)&w->WScreen->BitMap;
winfo->wi_WhichPlane = 0;
winfo->wi_Left = 10;
winfo->wi_Top = 3;
winfo->wi_Width = 60;
winfo->wi_Height = 21;
InitWarpInfo(winfo);
/* warp out text */
for (i = 0; i < 17; i++)
WarpText(winfo, text[i], strlen(text[i]));
GotoXY(winfo, 25, 19);
WarpText(winfo, "Hey, I'm here!", 14);
GotoXY(winfo, 10, 20);
WarpText(winfo, "And here!!", 10);
CloseFont(winfo->wi_TextFont);
for (;;) {
WaitPort(w->UserPort);
msg = (struct IntuiMessage *)GetMsg(w->UserPort);
ReplyMsg(msg);
class = msg->Class;
switch (class) {
case CLOSEWINDOW:
closestuff();
break;
}
}
}
void MemCleanup() {} /* Lattice stub */